import numpy as np
import matplotlib.pyplot as plt
import os

list_temp = []
for root, dirs, files in os.walk("."):
    for filename in files:
        list_temp.append(filename)

kw = ['FFT']

filelist = []
for items in list_temp:
    for ele in kw:
        if ele in items:
            filelist.append(items)

fft_sum = np.zeros([132000,2])
for i in range(len(filelist)):
    a = np.loadtxt(filelist[i]) 
    fft_sum = fft_sum + a

fft_sum = fft_sum/(i+1)

np.savetxt('sum_fft.txt',fft_sum)
plt.plot(fft_sum[:,0],fft_sum[:,1])
plt.xlim(0,80)
plt.show()
